package com.example.demo.entity.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xkx
 * @date 2018/12/24
 */
public class Girl implements Subject {

  private List<Observer> observerList;

  public Girl() {
    this.observerList = new ArrayList<>();
  }

  @Override
  public void addObserver(Observer observer) {
    observerList.add(observer);
  }

  @Override
  public void removeObserver(Observer observer) {
    observerList.remove(observer);
  }

  @Override
  public void notifyObservers() {
    observerList.forEach(observer -> observer.update());
  }

  public void hungry() {
    notifyObservers();
  }
}
